package com.tyut.rxtnongyespringboot.mapper;

import com.tyut.rxtnongyespringboot.bean.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    @Select("select * from tb_user where user_name=#{use_name}")
    public User getUserByuser_name(String use_name);

    @Insert("insert into tb_user (user_name, password, nick_name, phone, identity_num, address, role, create_time, update_time, integral, credit, avatar, real_name) " +
            "values (#{user_name}, #{password}, #{nick_name}, #{phone}, #{identity_num}, #{address}, #{role}, #{create_time}, #{update_time}, #{integral}, #{credit}, #{avatar}, #{real_name})")
    public int insertUser(User user);

    @Update("update tb_user set user_name = #{user_name}, password = #{password}, nick_name = #{nick_name}, phone = #{phone}, " +
            "identity_num = #{identity_num}, address = #{address}, role = #{role}, create_time = #{create_time}, " +
            "update_time = #{update_time}, integral = #{integral}, credit = #{credit}, avatar = #{avatar}, real_name = #{real_name} " +
            "where id = #{id}")
    public int updateUser(User user);
}